<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BookRecommend extends Model
{

    protected $guarded = [];


    public function book(){

        return $this->belongsTo(Book::class);
    }


    protected static function boot()
    {


        static::updated(function ($recommend){

            if (empty($recommend->heavy_at)
                && empty($recommend->masterpiece_at)
                && empty($recommend->recommend_at)
                && empty($recommend->ys_recommend_at)
                && empty($recommend->week_choiceness_at)

                ){

                $recommend->delete();
            }
        });

        parent::boot();
    }


}
